Skip to content

fix: always attempt to resolve identity-hash & certificate-name - #458

Open
Bug-Reaper wants to merge 2 commits into
electron:mainfrom
Bug-Reaper:fix/identity-info-catch22
Open

Bug-Reaper wants to merge 2 commits into
electron:mainfrom
Bug-Reaper:fix/identity-info-catch22

Conversation

@Bug-Reaper

Copy link
Copy Markdown

Original issue : #452
Improvement on : #454

Change Context

An incoming identity string will be either a certificate-name OR the identity-hash for a certificate. Technically the codesign binary we're wrapping allows for either.

Certain edge-cases require us to have the identity-hash to correctly invoke codesign. Other flows require us to have the certificate-name for automatic plist entitlement management done by osx-sign.

The above edge-cases can also overlap and occur at the same-time in certain build scenarios.

For those reasons, this PR adds code to always try and extrapolate the full certificate-name & identity-hash pair from whatever identity-part is being passed in as opts.identity.

Even when calling with opts.identityValidation=false we still attempt to find the full pair of identity info. In the spirit of identityValidation=false this includes expired/untrusted identities. If the full-pair of identity cannot be resolved and identityValidation=false then we return a new Identity() and just pass it the identity-part we have from opts.identity.

So we still attempt to create a full identity-hash & certificate-name pair with validation off, but we do not block a user from running a half-baked identity if we cannot resolve the full-pair.

CC @mmaietta

We need both for different edge-cases that can also overlap. For that reason we do this even if validation is turned off. If validation is off, an unresolved identity-part will still be as-is to `new Identity(opts.identity <RawInputString>)` & this preserves older behavior. More info here electron#452
@Bug-Reaper
Bug-Reaper requested a review from a team as a code owner October 2, 2026 04:31
@Bug-Reaper Bug-Reaper changed the title Always attempt to resolve identity-hash & certificate-name fix: always attempt to resolve identity-hash & certificate-name Oct 2, 2026
…y find-identity`

Now that we allow `security find-identity` w/o `-v` we must accomodate for a result which will contain all valid identities twice.
@Bug-Reaper

Bug-Reaper commented Oct 2, 2026 •

Copy link
Copy Markdown
Author

It didn't look like compactFlattenedList de-duplicated the raw identity results from security find-identity CLI call.

As mention in discussion elsewhere, since we now run security find-identity on all identities (when verify is false). The raw results contain all valid identities in the result twice.

Here's an example log of the differing outputs of `security find-identity`
👉 security find-identity -v            
 1) FC1A16756489E49CD3F03D55A89FAB453C0E7C7B "Developer ID Installer: tim apple (ZZZZZZZZZZ)"
 2) 148EBF0A1F92BC0BF106BE497AA5135C2E33E199 "Developer ID Installer: tim apple (ZZZZZZZZZZ)"
 3) 148EBF0A1F92BC0BF106BE497AA5135C2E33E199 "Developer ID Installer: tim apple (ZZZZZZZZZZ)"
 4) E8AF00545728444E4B2439B28054962FF9F5D58C "Developer ID Application: tim apple (ZZZZZZZZZZ)"
 5) D37C92D2935AC1F1AE6F317CFEBE510295A409D3 "Developer ID Installer: tim apple (ZZZZZZZZZZ)"
 6) 082F22402E3FCF18C19E959ECC5963836370BB9E "Developer ID Application: tim apple (ZZZZZZZZZZ)"
 7) 082F22402E3FCF18C19E959ECC5963836370BB9E "Developer ID Application: tim apple (ZZZZZZZZZZ)"
 8) 082F22402E3FCF18C19E959ECC5963836370BB9E "Developer ID Application: tim apple (ZZZZZZZZZZ)"
 9) 082F22402E3FCF18C19E959ECC5963836370BB9E "Developer ID Application: tim apple (ZZZZZZZZZZ)"
10) 148EBF0A1F92BC0BF106BE497AA5135C2E33E199 "Developer ID Installer: tim apple (ZZZZZZZZZZ)"
11) 148EBF0A1F92BC0BF106BE497AA5135C2E33E199 "Developer ID Installer: tim apple (ZZZZZZZZZZ)"
    11 valid identities found

👉 security find-identity               

Policy: X.509 Basic
 Matching identities
 1) FC1A16756489E49CD3F03D55A89FAB453C0E7C7B "Developer ID Installer: tim apple (ZZZZZZZZZZ)"
 2) 2A3E1E027C6C6311A0B66087E092C2931BE88DF1 "Developer ID Application: tim apple (ZZZZZZZZZZ)" (CSSMERR_TP_CERT_EXPIRED)
 3) 148EBF0A1F92BC0BF106BE497AA5135C2E33E199 "Developer ID Installer: tim apple (ZZZZZZZZZZ)"
 4) 148EBF0A1F92BC0BF106BE497AA5135C2E33E199 "Developer ID Installer: tim apple (ZZZZZZZZZZ)"
 5) E8AF00545728444E4B2439B28054962FF9F5D58C "Developer ID Application: tim apple (ZZZZZZZZZZ)"
 6) D37C92D2935AC1F1AE6F317CFEBE510295A409D3 "Developer ID Installer: tim apple (ZZZZZZZZZZ)"
 7) 082F22402E3FCF18C19E959ECC5963836370BB9E "Developer ID Application: tim apple (ZZZZZZZZZZ)"
 8) 082F22402E3FCF18C19E959ECC5963836370BB9E "Developer ID Application: tim apple (ZZZZZZZZZZ)"
 9) 082F22402E3FCF18C19E959ECC5963836370BB9E "Developer ID Application: tim apple (ZZZZZZZZZZ)"
10) 082F22402E3FCF18C19E959ECC5963836370BB9E "Developer ID Application: tim apple (ZZZZZZZZZZ)"
11) 148EBF0A1F92BC0BF106BE497AA5135C2E33E199 "Developer ID Installer: tim apple (ZZZZZZZZZZ)"
12) 148EBF0A1F92BC0BF106BE497AA5135C2E33E199 "Developer ID Installer: tim apple (ZZZZZZZZZZ)"
    12 identities found

 Valid identities only
 1) FC1A16756489E49CD3F03D55A89FAB453C0E7C7B "Developer ID Installer: tim apple (ZZZZZZZZZZ)"
 2) 148EBF0A1F92BC0BF106BE497AA5135C2E33E199 "Developer ID Installer: tim apple (ZZZZZZZZZZ)"
 3) 148EBF0A1F92BC0BF106BE497AA5135C2E33E199 "Developer ID Installer: tim apple (ZZZZZZZZZZ)"
 4) E8AF00545728444E4B2439B28054962FF9F5D58C "Developer ID Application: tim apple (ZZZZZZZZZZ)"
 5) D37C92D2935AC1F1AE6F317CFEBE510295A409D3 "Developer ID Installer: tim apple (ZZZZZZZZZZ)"
 6) 082F22402E3FCF18C19E959ECC5963836370BB9E "Developer ID Application: tim apple (ZZZZZZZZZZ)"
 7) 082F22402E3FCF18C19E959ECC5963836370BB9E "Developer ID Application: tim apple (ZZZZZZZZZZ)"
 8) 082F22402E3FCF18C19E959ECC5963836370BB9E "Developer ID Application: tim apple (ZZZZZZZZZZ)"
 9) 082F22402E3FCF18C19E959ECC5963836370BB9E "Developer ID Application: tim apple (ZZZZZZZZZZ)"
10) 148EBF0A1F92BC0BF106BE497AA5135C2E33E199 "Developer ID Installer: tim apple (ZZZZZZZZZZ)"
11) 148EBF0A1F92BC0BF106BE497AA5135C2E33E199 "Developer ID Installer: tim apple (ZZZZZZZZZZ)"

Added a second commit to keep a Set() of identity hashes as we parse results. This ensures duplicate identities aren't accumulated with our new usage of security find-identity.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant